using System.Collections;
using System.Text;

namespace Trentacular.SharePoint.StsAdmin.Util
{
	/// <summary>
	/// Summary description for Util.
	/// </summary>
	public static class StringUtils
    {
		public static string Delimit(ICollection input, string startDelimiter, string endDelimiter)
		{
			StringBuilder sb = new StringBuilder();
			foreach(object s in input)
			{
				sb.Append(startDelimiter).Append(s.ToString()).Append(endDelimiter);
			}
			return sb.ToString();
		}

		public static string Delimit(IEnumerable input, string delimiter)
		{
			StringBuilder sb = new StringBuilder();

			foreach (object o in input)
			{
				sb.Append(o==null? "" : o.ToString());
				sb.Append(delimiter);
			}

			if (sb.Length > 0) {
				sb.Remove(sb.Length - delimiter.Length, delimiter.Length);
			}

			return sb.ToString();
		}
	}
}
